#include "QGSP_BERT_HP.hh"
#include "BeginnerGeometry.h"
#include "ParticleSource.h"
#include "G4MTRunManager.hh"
#include "Beginner_initialization.hh"
#include "G4UImanager.hh"
#include "G4UIExecutive.hh"
#include "G4VisExecutive.hh"
int main(int argc, char **argv)
{
    G4UIExecutive *ui = nullptr;
    if (argc == 1)
    {
        ui = new G4UIExecutive(argc, argv);
    }
    auto runManager = new G4MTRunManager;
    runManager->SetUserInitialization(new BeginnerGeomotry());
    runManager->SetUserInitialization(new QGSP_BERT_HP());
    runManager->SetUserInitialization(new Beginner_initialization());

    auto visManager = new G4VisExecutive;
    visManager->Initialise();

    auto UImanager = G4UImanager::GetUIpointer();
    if (!ui)
    {
        G4String command = "/control/execute ";
        G4String filename = argv[1];
        UImanager->ApplyCommand(command + filename);
    }
    else
    {
        UImanager->ApplyCommand("/control/execute vis.mac");
        ui->SessionStart();
        delete ui;
    }
    // UImanager->ApplyCommand("/control/execute auto.mac");

    delete runManager, visManager;
    return 0;
}
